package com.example.websocketserver.util;

/**
 * @Author : zzd
 * @Date : 2020/8/26 19:56
 * @Version: 1.0
 * @Description :
 */
public class ResultUtil {

    public static Result success(Object object) {
        return success(ResultEnum.SUCCESS,object);
    }

    public static Result success() {
        return success(null);
    }

    public static Result success(ResultEnum resultEnum,Object data) {
        Result result = new Result();

        result.setCode(resultEnum.getCode());
        result.setMsg(resultEnum.getMsg());
        result.setData(data);

        return result;
    }

    public static Result error(ResultEnum resultEnum) {
        Result result = new Result();

        result.setCode(resultEnum.getCode());
        result.setMsg(resultEnum.getMsg());

        return result;
    }

    public static Result error(String msg) {
        Result result = new Result();
        result.setCode(500);
        result.setMsg(msg);
        return result;
    }

}
